package com.xdjmall.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Utils {

	private static String md5(String src){
		//1.创建一个摘要
		MessageDigest md5 = null;
		try {
			md5 = MessageDigest.getInstance("md5");
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		//2.把要加密的字符串转成byte数组，进行摘要
		byte[] digest = md5.digest(src.getBytes());
		//3.创建一个大数字,把加密后的摘要转成16进制大数字
		String string = new BigInteger(1,digest).toString(16);
		return string;
	}
}
